--- title: OpenHSI Class keywords: fastai sidebar: home_sidebar summary: "The bridge between camera implementations and the rest of `openhsi` land." description: "The bridge between camera implementations and the rest of `openhsi` land." nb_path: "nbs/01_capture.ipynb" ---
{% include warning.html content='Running in notebook slow downs the camera more than running in a script. ' %}
To add a custom camera, five methods need to be defined in a class to:
__init__, andstart_cam, andstop_cam, andget_img, andset_exposure, andget_temp.By inheriting from the OpenHSI class, all the methods to load settings/calibration files, collect datacube, saving data to NetCDF, and viewing as RGB are integrated. Furthermore, the custom camera class can be passed to a SettingsBuilder class for calibration.
For example, we implement a simulated camera below.
with SimulatedCamera(img_path="assets/great_hall_slide.png", n_lines=1028, processing_lvl = 3,
json_path="assets/cam_settings.json",pkl_path="assets/cam_calibration.pkl") as cam:
cam.collect()
fig = cam.show(plot_lib="matplotlib",hist_eq=True)
fig.opts(fig_inches=7,title="simulated hyperspectral datacube")
Each RGB value is converted into a pseudo-spectra by using the CIE XYZ matching functions.
json_path='../calibration_files/OpenHSI-16_settings_Mono8_bin2.json'
pkl_path='../calibration_files/OpenHSI-16_calibration_Mono8_bin2_window.pkl'
with ProcessRawDatacube(fname = "../../Downloads/16_pvn1_bin2_10ms2022_01_13-04_22_25.nc", processing_lvl=7,
json_path=json_path, pkl_path=pkl_path) as cam:
cam.collect()
fig = cam.show(hist_eq=True)
fig